#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

int majorityElement(int* nums, int numsSize) {
    int* temp = (int*)malloc(sizeof(int) * numsSize);
    int index = 0;
    for (int i = 0; i < numsSize; i++)
    {
        int count = 0;
        int rec = 0;
        for (int j = 0; j < index; j++)
        {
            if (temp[j] == nums[i])
                rec = 1;
        }
        if (rec == 0)
        {
            for (int j = 0; j < numsSize; j++)
            {
                if (nums[i] == nums[j])
                {
                    count++;
                }
                if (count * 2 >= numsSize)
                {
                    return nums[i];
                }
            }
            temp[index] = nums[i];
            index++;
        }
    }
    return 1;
}

int main()
{
	int arr[] = { 2, 2, 1, 1, 1, 2, 2 };
    printf("%d", majorityElement(arr, 7));
	return 0;
}